﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Configuration;

namespace SysAdmin._01_Config
{
    public static class MyConfig
    {
        public static string RemoteHostAddr { get; private set; }
        public static string WebToolAddr { get; private set; }
        public static int RootUserId { get; private set; }
        public static int MTCPUserId { get; private set; }
        public static IList<string> ProductNames { get; private set; } = new List<string>();

        static MyConfig()
        {
            RemoteHostAddr = ConfigurationManager.AppSettings["RemoteHostAddr"];
            WebToolAddr = ConfigurationManager.AppSettings["WebToolAddr"];
            {
                int rootUserId = 0;
                bool b = int.TryParse(ConfigurationManager.AppSettings["RootUserId"], out rootUserId);
                if (b)
                {
                    RootUserId = rootUserId;
                }
            }
            {
                int mtcpUserId = 0;
                bool b = int.TryParse(ConfigurationManager.AppSettings["MTCPUserId"], out mtcpUserId);
                if (b)
                {
                    MTCPUserId = mtcpUserId;
                }
            }
            {
                string productNames = ConfigurationManager.AppSettings["ProductNames"];
                if (!string.IsNullOrEmpty(productNames))
                {
                    ProductNames = productNames.Split(',').Select(x => x.Trim()).ToList();
                }
            }
        }
    }
}
